package websocket

const (
	messageTypeJson = 0
	messageTypeText = 1

	messageFromLocal   = 0
	messageFromCluster = 1

	checkExistTypeUser  = 0
	checkExistTypeGroup = 1

	ActionJoinRoom  = 91
	ActionLeaveRoom = 92

	clusterActionSendMessage     = 1
	clusterActionGetUsers        = 2
	clusterActionCheckExists     = 3
	clusterActionCloseConnection = 4

	uriPrefix          = "/api/websocket"
	uriPrefixFramework = "/api/framework/websocket"
)

type LetsviewObject struct {
	Status  int         `json:"status"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}
type JsonObject struct {
	Status  int                  `json:"status"`
	Message string               `json:"message,omitempty"`
	Action  int                  `json:"action,omitempty"`
	Options *ActionMessageOption `json:"options,omitempty"`
	Data    interface{}          `json:"data,omitempty"`
}
type ActionMessage struct {
	Action  int                  `json:"action" v:"required"`
	Options *ActionMessageOption `json:"options,omitempty"`
	Data    interface{}          `json:"data,omitempty"`
}
type ActionMessageOption struct {
	To       []interface{} `json:"to,omitempty"`
	From     interface{}   `json:"from,omitempty"`
	ToUsers  []int         `json:"-"`
	ToGroups []string      `json:"-"`
	FD       int64         `json:"fd,omitempty"`
	ReqId    interface{}   `json:"req_id,omitempty"`
	MsgId    int           `json:"msg_id,omitempty"`
}

type clusterAction struct {
	Action int         `json:"action,omitempty"`
	Data   interface{} `json:"data,omitempty"`
}
type clusterSendMessageObject struct {
	Data    *JsonObject `json:"data,omitempty"`
	GroupId string      `json:"group_id,omitempty"`
	Users   []int       `json:"users,omitempty"`
}
type clusterCheckExistsObject struct {
	Type    int    `json:"type"`
	GroupId string `json:"group_id,omitempty"`
	UserId  int    `json:"user_id,omitempty"`
}
type clusterCloseConnectionObject struct {
	GroupId string `json:"group_id,omitempty"`
	FD      int64  `json:"fd,omitempty"`
}
